<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>陕西省交通地理信息共享服务平台－资源展示平台</title>
    <link rel="stylesheet" href="dzdtApp/resources/app.css">
    <link rel="stylesheet" href="framework/ztree/jquery.zTree/zTreeStyle/zTreeStyle.css">
    <link rel="stylesheet" href="framework/easyui1.3.2/themes/default/easyui.css">
    <link rel="stylesheet" href="framework/jquery/jquery.autocomplete.css">
    <link rel="stylesheet" href="framework/jquery/icheck/skins/square/_all.css">

</head>
<body class="claro" style="min-width: 1000px; min-height: 600px;">
<script src="dzdtApp/dzdtAppConfig.js"></script>
<!--<div class="loading">加载中…</div>-->
<script>
    console.info(dzdtAppConfig);
    var path_location = location.pathname.replace(/\/[^/]+$/, '');
    dojoConfig = {
        async: true,
        isDebug: true,
        packages: [
            {
                name: "dzdtApp",
                location: path_location + "/dzdtApp"
            },
            {
                location: dzdtAppConfig.mapDataService + "/api/",//"http://192.168.0.112:8001/mapdata/api/",
                main: "MapDataAPI1.0",
                name: "MapData"
            }
        ],
        selectorEngine: 'lite',
        customConfig: {
            headMenu: "公路专题",
            QueryStatistics: "查询"
        }
    };

</script>
<!--<script src="dzdtApp/resources/init.js"></script>-->
<script src="framework/echarts/echarts-plain.js"></script>
<script src="framework/jquery/jquery-1.8.0.min.js"></script>
<script src="framework/jquery/jquery.autocomplete.min.js"></script>
<script src="framework/easyui1.3.2/jquery.easyui.min.js"></script>
<script src="framework/easyui1.3.2/easyui-lang-zh_CN.js"></script>
<script src="framework/ztree/jquery.zTree/jquery.ztree.all-3.5.min.js"></script>
<script src="framework/jquery/icheck/icheck.js"></script>
<script src="http://211.101.37.251:68/arcgis_js_api/library/3.10/3.10/init.js"></script>
<!-- <script src="http://10.228.2.73/arcgis_js_api/library/3.10/3.10/init.js"></script> -->
<script src="framework/utils/YMLib.js"></script>
<script>
    require(["dzdtApp/main"], function (main) {
    });
    $(document.body).ready(function () {

        $("#btnPoint").bind("click", function () {
            /*  queryLayer({//直接调用数据访问更新服务API
             layerName:"gis_ql",
             where:"id='487f6ef0-1d01-4bd7-a8a3-43510c4aef69'",
             geoFormatType:2
             });  */
            require(["dzdtApp/MapDataUtil"], function (MapDataUtil) {
                console.info(MapDataUtil);
                MapDataUtil.query({//针对平台再次对数据访问更新服务API进行封装
                    layerName: "gis_ql",
                    where: "id='487f6ef0-1d01-4bd7-a8a3-43510c4aef69'"
                });
            });
        });
        $("#btnLine").bind("click", function () {
            queryLayer({//直接调用数据访问更新服务API
                layerName: "gis_lx",
                where: "LXDM='S19'",
                geoFormatType: 2
            });
        });
        $("btnPolygon").bind("click", function () {

        });
    });
    function queryLayer(params) {
        require(["MapData", "esri/graphicsUtils"], function (MapData, graphicsUtils) {
            var mapData = new MapData(params);
            mapData.sendRequest(function (data) {
                var features = data.features;
                dzdtAppConfig.map.graphics.clear();
                for (var i = 0; i < features.length; i++) {
                    var geometryType = features[i].geometryType;
                    var graphic = null;
                    if (geometryType == "Point") {
                        drawPoint(features[i]);
                    } else if (geometryType == "LineString") {
                        drawLine(features[i]);
                    }
                }
                var extent = graphicsUtils.graphicsExtent(dzdtAppConfig.map.graphics.graphics);
                dzdtAppConfig.map.setExtent(extent);
            });
        });
    }
    function drawPoint(point) {
        require(["esri/graphic", "esri/geometry/Point",
            "esri/symbols/PictureMarkerSymbol",
            "esri/dijit/InfoWindow",
            "esri/InfoTemplate"], function (Graphic, Point, PictureMarkerSymbol, InfoWindow, InfoTemplate) {
            var mapPoint = new Point(point.geometry);
            var infoTemplate = new InfoTemplate("详细信息", "测试一下啊");
            var symbol = PictureMarkerSymbol("dzdtApp/resources/image/zh.png", 20, 20);
            var graphic = new Graphic(mapPoint, symbol);
            graphic.setInfoTemplate(infoTemplate);
            dzdtAppConfig.map.graphics.add(graphic);
            return graphic;
        });
    }
    function drawLine(line) {
        require(["esri/graphic", "esri/geometry/Polyline",
            "esri/Color",
            "esri/symbols/SimpleLineSymbol",
            "esri/dijit/InfoWindow",
            "esri/InfoTemplate"], function (Graphic, Polyline, Color, SimpleLineSymbol, InfoWindow, InfoTemplate) {
            var mapLine = new Polyline(line.geometry);
            var infoTemplate = new InfoTemplate("详细信息", "测试一下啊");
            var symbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 255]), 5);
            var graphic = new Graphic(mapLine, symbol);
            graphic.setInfoTemplate(infoTemplate);
            dzdtAppConfig.map.graphics.add(graphic);
            return graphic;
        });
    }
</script>
<div style="position: absolute;z-index: 10000;bottom:10px;right: 20px">
    <button id="btnPoint">点查询测试</button>
    <button id="btnLine">线查询测试</button>
    <button id="btnPolygon">面查询测试</button>
</div>
</body>
</html>
